﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Course.Service.EFCore.Interface
{
    public interface ICouresService<T> where T : class, new()
    {
        /// <summary>
        /// 查询所有
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        IQueryable<T> QueryAll(Expression<Func<T, bool>>? where);

        /// <summary>
        /// 排序
        /// </summary>
        /// <typeparam name="type"></typeparam>
        /// <param name="order"></param>
        /// <param name="isAsc"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        IQueryable<T> QueryAll<type>(Expression<Func<T, type>> order, bool isAsc = true, Expression<Func<T, bool>>? where = null);

        /// <summary>
        /// 分页
        /// </summary>
        /// <typeparam name="type"></typeparam>
        /// <param name="total"></param>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="order"></param>
        /// <param name="isAsc"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        IQueryable<T> QueryAll<type>(out int total, int page, int limit, Expression<Func<T, type>> order, bool isAsc = true, Expression<Func<T, bool>>? where = null);

        /// <summary>
        /// 单个新增
        /// </summary>
        /// <param name="t"></param>
        void Add(T t);

        /// <summary>
        /// 多个新增
        /// </summary>
        /// <param name="ie"></param>
        void AddRange(IEnumerable<T> ie);

        /// <summary>
        /// 单个修改
        /// </summary>
        /// <param name="t"></param>
        void Update(T t);

        /// <summary>
        /// 多个修改
        /// </summary>
        /// <param name="ie"></param>
        void UpdateRange(IEnumerable<T> ie);

        /// <summary>
        /// 单个删除
        /// </summary>
        /// <param name="t"></param>
        void Delete(T t);

        /// <summary>
        /// 多个删除
        /// </summary>
        /// <param name="ie"></param>
        void DeleteRange(IEnumerable<T> ie);

        /// <summary>
        /// 保存操作
        /// </summary>
        /// <returns></returns>
        int SaveChanges();
    }
}
